Skip to content

fix: call onClose when askAi is active#2810

Closed
mguida22 wants to merge 1 commit into
algolia:mainfrom
mguida22:fix/2809-search-captures-keystrokes
Closed

fix: call onClose when askAi is active#2810
mguida22 wants to merge 1 commit into
algolia:mainfrom
mguida22:fix/2809-search-captures-keystrokes

Conversation

@mguida22
Copy link
Copy Markdown

@mguida22 mguida22 commented Nov 27, 2025

Calls onClose when closing the modal via Escape and isAskAiActive is true. This follows the behavior of an Escape keypress when isAskAiActive is false.

Fixes #2809.

(this is a guess, I still need to figure out testing this)

@netlify
Copy link
Copy Markdown

netlify Bot commented Nov 27, 2025

👷 Deploy request for docsearch pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 87da6cc

@netlify
Copy link
Copy Markdown

netlify Bot commented Nov 27, 2025

Deploy Preview for docsearch-demo ready!

Name Link
🔨 Latest commit 87da6cc
🔍 Latest deploy log https://app.netlify.com/projects/docsearch-demo/deploys/6928a60388f7a30007e2b970
😎 Deploy Preview https://deploy-preview-2810--docsearch-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

function onKeyDown(event: KeyboardEvent): void {
if (isOpen && event.code === 'Escape' && isAskAiActive) {
onAskAiToggle(false);
onClose();
Copy link
Copy Markdown
Contributor

@8bittitan 8bittitan Dec 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe these are the correct places for this. This block is meant to "leave" the Ask AI experience and go back to the keyword search experience, without closing the modal.

I believe the issue is more that the cleanup of this useEffect is not getting ran, causing the keydown event listener to never get removed.

The root issue for the modal opening again is that we focus the search button on close, and then have a listener that opens the modal again on keypress if the search button is the focused element.

@mguida22 mguida22 closed this Dec 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DocSearch v4 modal re-opens on every keystroke after using using cmd+k + 'esc

2 participants